
package com.probiz.estoremf;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.probiz.estore.common.helper.ConfigUtil;
import com.probiz.estore.core.controller.BaseController;

public class LoginController extends BaseController {

	public ModelAndView defaultAction(HttpServletRequest request, HttpServletResponse response) throws ServletException {
		if(ConfigUtil.getInstance().isOpenCasService()){
			StringBuffer buffer = new StringBuffer();
			buffer.append(ConfigUtil.getInstance().getCasServerUrl()).append("/login?service=");
			//由于postLogin已被acegi授权保护，经过filter链，所以登录名称问题已处理。而且PostLoginController本身就应该是登录后的处理中心
			buffer.append(ConfigUtil.getInstance().getStoreFrontSiteUrl()).append("/postLogin.html");
			//1.此方案导致问题：不会显示登录名称
			//buffer.append(ConfigUtil.getInstance().getStoreFrontSiteUrl()).append("/index.html");
			//2.此方案导致问题：不人性化
			//buffer.append(ConfigUtil.getInstance().getStoreFrontSiteUrl()).append("/customer/index.html");
			//3.此方案导致问题：死循环链
			//buffer.append(ConfigUtil.getInstance().getStoreFrontSiteUrl()).append("/j_security_check");
			return new ModelAndView(new RedirectView(buffer.toString()));
		}else{
			return new ModelAndView("customer/login");
		}
	}

	

}
